using System.Web.Mvc;
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;

namespace MvcCms.Web.Ioc.Installers
{
    public class MvcCmsWikiPlexInstaller : IWindsorInstaller
	{
		#region IWindsorInstaller Members

		public void Install(IWindsorContainer container, IConfigurationStore store)
		{
            container.Register(AllTypes.FromAssemblyNamed("MvcCmsWikiPlex")
                                .BasedOn<IController>()
                                .If(t => t.Name.EndsWith("Controller"))
                                .Configure((c => c.LifeStyle.Transient)));


            container.Register(AllTypes.FromAssemblyNamed("MvcCmsWiki.Service")
                                .Where(type => type.Name.EndsWith("Service"))
                                .WithService.DefaultInterface()
                                .Configure(c => c.LifeStyle.Transient));

            container.Register(AllTypes.FromAssemblyNamed("MvcCmsWiki.Data")
                                .Where(type => type.Name.EndsWith("Repository"))
                                .WithService.DefaultInterface()
                                .Configure(c => c.LifeStyle.Transient));
		}

		#endregion
	}
}